<HTML><HEAD><TITLE>library(test_util)</TITLE></HEAD><BODY>
[ <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]<H1>library(test_util)</H1>
Utilities for automated program tests
<H2>Predicates</H2>
<BLOCKQUOTE>
<DL>
<DT><A HREF="get_failed_test_count-1.html"><STRONG>get_failed_test_count(-N)</STRONG></A></DT>
<DD>Returns the number of tests that failed.</DD>
<DT><STRONG>make_atom(?)</STRONG></DT>
<DD>No description available</DD>
<DT><STRONG>make_bignum(?)</STRONG></DT>
<DD>No description available</DD>
<DT><STRONG>make_float(?)</STRONG></DT>
<DD>No description available</DD>
<DT><STRONG>make_integer(?)</STRONG></DT>
<DD>No description available</DD>
<DT><STRONG>make_interval(?)</STRONG></DT>
<DD>No description available</DD>
<DT><STRONG>make_list(?)</STRONG></DT>
<DD>No description available</DD>
<DT><STRONG>make_negbignum(?)</STRONG></DT>
<DD>No description available</DD>
<DT><STRONG>make_negfloat(?)</STRONG></DT>
<DD>No description available</DD>
<DT><STRONG>make_neginteger(?)</STRONG></DT>
<DD>No description available</DD>
<DT><STRONG>make_neginterval(?)</STRONG></DT>
<DD>No description available</DD>
<DT><STRONG>make_negrational(?)</STRONG></DT>
<DD>No description available</DD>
<DT><STRONG>make_nil(?)</STRONG></DT>
<DD>No description available</DD>
<DT><STRONG>make_rational(?)</STRONG></DT>
<DD>No description available</DD>
<DT><STRONG>make_string(?)</STRONG></DT>
<DD>No description available</DD>
<DT><STRONG>make_struct(?)</STRONG></DT>
<DD>No description available</DD>
<DT><STRONG>make_var(?)</STRONG></DT>
<DD>No description available</DD>
<DT><A HREF="should_fail-1.html"><STRONG>+Goal should_fail</STRONG></A></DT>
<DD>Run the goal Goal and print a message if it doesn't fail</DD>
<DT><A HREF="should_fail-2.html"><STRONG>should_fail(+Goal,+TestName)</STRONG></A></DT>
<DD>Run the goal Goal and print a message if it doesn't fail</DD>
<DT><A HREF="should_give-2.html"><STRONG>+Goal should_give +CheckGoal</STRONG></A></DT>
<DD>Run the goal Goal and print a message if the result doesn't satisfy CheckGoal</DD>
<DT><A HREF="should_give-3.html"><STRONG>should_give(+Goal,+CheckGoal,+TestName)</STRONG></A></DT>
<DD>Run the goal Goal and print a message if the result doesn't satisfy CheckGoal</DD>
<DT><A HREF="should_raise-2.html"><STRONG>+Goal should_raise +Event</STRONG></A></DT>
<DD>Run the goal Goal and print a message if it doesn't raise Event.</DD>
<DT><A HREF="should_raise-3.html"><STRONG>should_raise(+Goal,+Event,+TestName)</STRONG></A></DT>
<DD>Run the goal Goal and print a message if it doesn't raise Event.</DD>
<DT><A HREF="should_throw-2.html"><STRONG>+Goal should_throw +Exception</STRONG></A></DT>
<DD>Run the goal Goal and print a message if it doesn't throw Exception</DD>
<DT><A HREF="should_throw-3.html"><STRONG>should_throw(+Goal,+Exception,+TestName)</STRONG></A></DT>
<DD>Run the goal Goal and print a message if it doesn't throw Exception</DD>
<DT><A HREF="test-1.html"><STRONG>test(+File)</STRONG></A></DT>
<DD>Runs all the test patterns in File.</DD>
<DT><A HREF="test-2.html"><STRONG>test(+File, +Option)</STRONG></A></DT>
<DD>Runs all the test patterns in File.</DD>
<DT><A HREF="test_info-2.html"><STRONG>test_info(+File,+Info)</STRONG></A></DT>
<DD>Runs all the test patterns in File, printing the Info string in test_csv_log.</DD>
</DL>
</BLOCKQUOTE>
<H2>Other Exports</H2>
<BLOCKQUOTE><DL>
<DT><STRONG>export op(1110, xfx, should_give)</STRONG></DT><DD></DD>
<DT><STRONG>export op(1110, xf, should_fail)</STRONG></DT><DD></DD>
<DT><STRONG>export op(1110, xfx, should_throw)</STRONG></DT><DD></DD>
<DT><STRONG>export op(1110, xfx, should_raise)</STRONG></DT><DD></DD>
</DL></BLOCKQUOTE>
<H2>Description</H2>

    Use this library as follows: Write a file with test patterns, using
    the primitives should_fail/1, should_give/2, should_throw/2 and
    should_raise/2, e.g.
    <PRE>
    3.0 > 3 should_fail.
    X is 3.0+4 should_give X=7.0.
    exit_block(ball) should_throw ball.
    number_string(hello,_) should_raise 5.
    </PRE>
    The file name should have a .tst extension, e.g. mytests.tst.
    Then run all the test in the file by calling test(mytests).  This will
    print a message for every test pattern that does not behave as expected.
    The messages go to a stream called testlog (which defaults to output).

    <P>
    Alternatively, you can write a file with test patterns, using the
    primitives should_fail/2, should_give/3, should_throw/3 and
    should_raise/3, e.g.
    <PRE>
    should_fail(3.0 > 3, test_float_not_greater_than_integer).
    should_give(X is 3.0+4, X=7.0, test_float_plus_integer_equals_float).
    should_throw(exit_block(ball),ball,test_exit_block).
    should_raise(number_string(hello,_),5,test_raises_5).
    </PRE>
    Here the extra last argument serves as a name for the test (or a short
    description).  It can be an atom or a string and it is used to output
    results in comma separated format to a stream called test_csv_log
    (defaults to null), e.g. test(mytest) should output the following to
    test_csv_log:
    <PRE>
    test_float_not_greater_than_integer,pass,2001-10-29,16:59:20,0.00
    test_float_plus_integer_equals_float,pass,2001-10-29,16:59:20,0.01
    test_exit_block,pass,2001-10-29,16:59:20,0.00
    test_raises_5,pass,2001-10-29,16:59:20,0.00
    </PRE>
    The first value is the name of the test (last argument in test pattern).
    The second value is either `pass' or `fail' indicating whether the
    particular test was successful or not.  The third and fourth values show
    the date and time (UTC) the test was run (in ISO 8601 format).  The last
    value shows the CPU time taken to run the test.
    Extra values can be appended at the head of the comma separated values
    by using test_info/2, e.g. test_info(mytest,test_result) would change
    the output to test_csv_log as follows:
    <PRE>
    test_result,test_float_not_greater_than_integer,pass,2001-10-29,16:59:20,0.00
    test_result,test_float_plus_integer_equals_float,pass,2001-10-29,16:59:20,0.01
    test_result,test_exit_block,pass,2001-10-29,16:59:20,0.00
    test_result,test_raises_5,pass,2001-10-29,16:59:20,0.00
    </PRE>
    This can be extremely useful, as useful information as the name of the
    module tested, the directory where it is located, the name of the host,
    etc. can be added to the log. 
    
<H2>About</H2><UL COMPACT>
<LI><STRONG>Author: </STRONG>Joachim Schimpf, IC-Parc
<LI><STRONG>Copyright &copy; </STRONG>Cisco Systems, Inc
<LI><STRONG>Date: </STRONG>$Date: 2009/02/19 05:38:37 $
</UL>
<HR>Generated from test_util.eci on 2009-05-27 01:25
</BODY></HTML>
